package com.mine.distinctionteam.http;

import com.google.gson.GsonBuilder;
import com.mine.distinctionteam.bean.businessman.BusinessmanBean;
import com.mine.distinctionteam.bean.goods.GoodsBean;
import com.mine.distinctionteam.bean.myclass.ClassBean;
import com.mine.distinctionteam.bean.unused.UnUsedBean;
import com.mine.distinctionteam.config.UnUsedUrlConfig;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 *
 */
public class UnUsedHttpUtils {
    private static volatile UnUsedHttpUtils singleHttp;
    private Retrofit retrofit;
    private ILiangPinHui iLiangPinHui;

    private UnUsedHttpUtils(){
        retrofit=new Retrofit.Builder().baseUrl(UnUsedUrlConfig.Path.BASE_URL).addConverterFactory(GsonConverterFactory.create(new GsonBuilder().serializeNulls().create())).build();
        iLiangPinHui=retrofit.create(ILiangPinHui.class);
    }

    public static UnUsedHttpUtils getInstance() {
        if (singleHttp == null) {
            synchronized (UnUsedHttpUtils.class) {
                if (singleHttp == null) {
                    singleHttp = new UnUsedHttpUtils();
                }
            }
        }
        return singleHttp;
    }

    public void getUnUsedData(Map<String, String> params, Callback<UnUsedBean> callback) {
        Call<UnUsedBean> call = iLiangPinHui.getUnUsed(params);
        call.enqueue(callback);
    }
    public void getBusinessmanData(Map<String, String> params, Callback<BusinessmanBean> callback) {
        Call<BusinessmanBean> call = iLiangPinHui.getBusinessman(params);
        call.enqueue(callback);
    }
    public void getGoodsData(String id, Callback<GoodsBean> callback) {
        Call<GoodsBean> call = iLiangPinHui.getGoods(id);
        call.enqueue(callback);
    }
    public void getClassData(Map<String, String> params, Callback<ClassBean> callback) {
        Call<ClassBean> call = iLiangPinHui.getClass(params);
        call.enqueue(callback);
    }
}
